package com.sang.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
public class ModelTest1 {

    //如果不显式定义重定向，那默认会走转发
    @RequestMapping("/m1/t1")
    //访问/m1/t1跳转test.jsp之后url没有变化，代表是转发操作
    public String test1(Model model) {
        model.addAttribute("msg","ModelTest1");
        return "forward:/WEB-INF/jsp/test.jsp";
        //return "/WEB-INF/jsp/test.jsp";
    }

    @RequestMapping("/m2/t2")
    //重定向
    public String test2(Model model) {
        model.addAttribute("msg","ModelTest1");
        return "redirect:/index.jsp";
    }
    
}
